var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("HallConstant"),
l = t("BroadCastMessage"),
c = t("ChannelTool"),
d = t("HWSdk"),
h = t("Util"),
p = t("Sign"),
u = t("Global"),
f = t("RedPointControl "),
m = t("BaseStorage"),
_ = cc._decorator,
y = _.ccclass,
g = _.property,
v = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.boxPrefab = null,
        e.receiveBtn = null,
        e.receiveTxt = null,
        e.videoTxt = null,
        e.btnShowAd = null,
        e.signScripts = [],
        e.frames = [],
        e.videoIcon1 = null,
        e.TTVideoIcon1 = null,
        e.videoIcon2 = null,
        e.TTVideoIcon2 = null,
        e.canCallback = !1,
        e
    }
    return n(e, t),
    e.prototype.start = function() {
        h.Util.is_tt() && (this.videoIcon1.active = !1, this.TTVideoIcon1.active = !0, this.videoIcon2.active = !1, this.TTVideoIcon2.active = !0),
        r.default.isSignView = !0,
        h.Util.is_VIVO() ? h.Util.showBanner() : h.Util.hideBanner(),
        h.Util.hideHallBanner(),
        this.btnShowAd.active = !1,
        cc.resources.load("prefab/confirmRewardPanel");
        for (var t = 0; t < this.signScripts.length; t++) this.signScripts[t].init(this.frames);
        this.signScript = this.signScripts[m.BaseStorage.getInt(u.BaseStorageKey.SignDay, 1) - 1],
        this.btnStatus(),
        r.default.popup = this.node,
        f.RedPointControl.getInstance().cal(u.RedPointCalKey.Signin)
    },
    e.prototype.onEnable = function() {
        h.Util.event_dispatcher.register(this),
        this.canCallback = !0,
        h.Util.hideSingleCustomAd(),
        c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.HW ? d.default.Ins.showNativeInsertAd() : h.Util.showInterstitialAd(null, this.closeMatrixAdCB.bind(this),
        function() {
            h.Util.show_matrixAd()
        })
    },
    e.prototype.closeMatrixAdCB = function() {
        this.canCallback && (h.Util.showRightSingleCustomAd(), h.Util.showLeftSingleCustomAd())
    },
    e.prototype.onDisable = function() {
        this.canCallback = !1,
        h.Util.event_dispatcher.remove(this),
        h.Util.hideRightSingleCustomAd(),
        h.Util.hideLeftSingleCustomAd(),
        d.default.Ins.hideNativeInsertAd(),
        h.Util.hide_matrixAd()
    },
    e.prototype.signIn = function() {
        var t = this,
        e = m.BaseStorage.getInt(u.BaseStorageKey.clock, 0) + 1;
        m.BaseStorage.setInt(u.BaseStorageKey.clock, e),
        this.videoTxt.active ? h.Util.showRewardVideo(function() {
            t.signScript.signIn(t.boxPrefab, 3),
            t.btnStatus()
        }) : (this.signScript.signIn(this.boxPrefab, 1), this.btnStatus())
    },
    e.prototype.btnStatus = function() {
        switch (this.receiveBtn.node.active = !0, this.signScript.date == p.DateEnum.seventhDay || this.signScript.date == p.DateEnum.secondDay ? (this.videoTxt.getChildByName("three").active = !1, this.videoTxt.getChildByName("one").active = !0) : (this.videoTxt.getChildByName("three").active = !0, this.videoTxt.getChildByName("one").active = !1), m.BaseStorage.getInt(u.BaseStorageKey.clock, 0)) {
            case 0:
                this.receiveTxt.active = !0;
            break;
            case 1:
                this.receiveTxt.active = !1;
            break;
            default: this.receiveBtn.node.active = !1;
        }
        if (this.videoTxt.active = !this.receiveTxt.active, this.videoTxt.active) {
            var t = cc.repeatForever(cc.sequence(cc.scaleTo(1, 1.1), cc.scaleTo(1, 1)));
            this.videoTxt.parent.runAction(t)
        } else this.videoTxt.parent.stopAllActions();
        this.videoTxt.active && h.Util.videoExposure(u.VideoTab.dim8)
    },
    e.prototype.close = function() {
        r.default.isSignView = !1,
        l.default.getInstance().SendMessage(s.Broadcast_Func.Audio, s.Audio_ID.btn_click),
        f.RedPointControl.getInstance().cal(u.RedPointCalKey.Signin),
        this.node.destroy(),
        h.Util.showSingleCustomAd(),
        h.Util.showHallBanner(),
        h.Util.hideBanner(),
        r.default.bAuditMode && h.Util.hideNativeGridAd()
    },
    e.prototype.onShowNativeGridAd = function() {
        h.Util.clickNativeGridAd()
    },
    e.prototype.onDestroy = function() {
        r.default.popup = null
    },
    a([g(cc.Prefab)], e.prototype, "boxPrefab", void 0),
    a([g(cc.Button)], e.prototype, "receiveBtn", void 0),
    a([g(cc.Node)], e.prototype, "receiveTxt", void 0),
    a([g(cc.Node)], e.prototype, "videoTxt", void 0),
    a([g(cc.Node)], e.prototype, "btnShowAd", void 0),
    a([g([p.default])], e.prototype, "signScripts", void 0),
    a([g([cc.SpriteFrame])], e.prototype, "frames", void 0),
    a([g(cc.Node)], e.prototype, "videoIcon1", void 0),
    a([g(cc.Node)], e.prototype, "TTVideoIcon1", void 0),
    a([g(cc.Node)], e.prototype, "videoIcon2", void 0),
    a([g(cc.Node)], e.prototype, "TTVideoIcon2", void 0),
    a([y], e)
} (cc.Component);
o.default = v